<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible"="ie=edge">
    <link rel="stylesheet" href="bootstrap-3.3.7-dist\css\bootstrap.min.css">
    <script src="jquery-3.2.1.js"></script>
    <script src="bootstrap-3.3.7-dist\js\bootstrap.min.js"></script>
    <link rel="stylesheet" href="style.css">

    <title>购物车</title>
</head>
<script>
    $(document).ready(function () {
        $('.num').click(function () {
            var num = $(this).val();
            var result = +num + 1;//parseInt和+是一样的，把字符串转整形
        })
        $(".subtraction").click(function () {
            var num = $(this).parent().siblings('.num').val();//找到当前点击加减按钮旁边的数量输入框，才不会影响其他的输入框
            if (+num == 1)
                return;
            var result = +num - 1;
            $(this).parent().siblings('.num').val(result);
        })
        $(".addition").click(function () {
            var num = $(this).parent().siblings('.num').val();
            var result = +num + 1;
            $(this).parent().siblings('.num').val(result);
        })

    });

</script>

<body>
    <div class="container">
        <!-- 商品类型 -->
        <div class="row cart">
            <div class="col-md-6">
                <label class=""><input type="checkbox" value="1" id="opt"><span class="all">全选</span></label></li>
                <span class="info">商品信息</span>

            </div>
            <div class="col-md-6">
                <div class="col-md-3 ">单价</div>
                <div class="col-md-3 ">数量</div>
                <div class="col-md-3 ">金额</div>
                <div class="col-md-3 ">操作</div>
            </div>
        </div>

        <!-- 店铺名称 -->
        <div class="row cart">
            <div class="col-md-6">
                <label><input type="checkbox" value="2" class="shop"><span class="all">店铺：</span></label></li>
                <span class="infoa">灰姑娘极品小店</span>
            </div>
        </div>
        <div class="header-a">
            <div class="row">
                <!-- 左边 -->
                <div class="col-md-6">
                    <div class="col-md-4 imgs">
                        <label><input type="checkbox" value="3" class="pricet"></label></li>
                        <span><img src="images/1.jpg" alt=""></span>
                    </div>
                    <div class="col-md-4 main">
                        <ul>
                            <li><a href="#">毛毛鞋女秋冬2017新款韩版平底女靴尖头<br/>裸靴兔毛马丁靴粗跟短靴女</a></li>

                        </ul>
                        <span class="card">
                            <img src="images/xcard.png" alt="">
                            <img src="images/hp.png" alt="">
                            <img src="images/sz.jpg" alt="">
                        </span>
                    </div>
                    <div class="col-md-4 imgas">
                        <p>颜色分类：驼色</p>
                        <p>尺码：35</p>
                    </div>
                </div>
                <!-- 右边 -->
                <div class="col-md-6">
                    <div class="col-md-3">￥65.00</div>
                    <div class="col-md-3 price">
                        <span><a href="#" class="subtraction">-</a></span><input type="text" value="1" class="num"><span><a href="#" class="addition">+</a></span>
                    </div>
                    <div class="col-md-3 money">￥65.00</div>
                    <div class="col-md-3 main">
                        <ul>
                            <li><a href="#">移入收藏夹</a></li><br/>
                            <li><a href="#">删除</a></li><br/>
                            <li><a href="#">相似宝贝</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="row">
                <!-- 左边 -->
                <div class="col-md-6">
                    <div class="col-md-4 imgs">
                        <label><input type="checkbox" value="3" class="pricet"></label></li>
                        <span><img src="images/1.jpg" alt=""></span>
                    </div>
                    <div class="col-md-4 main">
                        <ul>
                            <li><a href="#">毛毛鞋女秋冬2017新款韩版平底女靴尖头<br/>裸靴兔毛马丁靴粗跟短靴女</a></li>

                        </ul>
                        <span class="card">
                                <img src="images/xcard.png" alt="">
                                <img src="images/hp.png" alt="">
                                <img src="images/sz.jpg" alt="">
                            </span>
                    </div>
                    <div class="col-md-4 imgas">
                        <p>颜色分类：驼色</p>
                        <p>尺码：35</p>
                    </div>
                </div>
                <!-- 右边 -->
                <div class="col-md-6">
                    <div class="col-md-3">￥65.00</div>
                    <div class="col-md-3 price">
                        <span><a href="#" class="subtraction">-</a></span><input type="text" value="1" class="num"><span><a href="#" class="addition">+</a></span>
                    </div>
                    <div class="col-md-3 money">￥65.00</div>
                    <div class="col-md-3 main">
                        <ul>
                            <li><a href="#">移入收藏夹</a></li><br/>
                            <li><a href="#">删除</a></li><br/>
                            <li><a href="#">相似宝贝</a></li>
                        </ul>
                    </div>
                </div>


            </div>

            <div class="row">
                <!-- 左边 -->
                <div class="col-md-6">
                    <div class="col-md-4 imgs">
                        <label><input type="checkbox" value="3" class="pricet"></label></li>
                        <span><img src="images/1.jpg" alt=""></span>
                    </div>
                    <div class="col-md-4 main">
                        <ul>
                            <li><a href="#">毛毛鞋女秋冬2017新款韩版平底女靴尖头<br/>裸靴兔毛马丁靴粗跟短靴女</a></li>

                        </ul>
                        <span class="card">
                                <img src="images/xcard.png" alt="">
                                <img src="images/hp.png" alt="">
                                <img src="images/sz.jpg" alt="">
                            </span>
                    </div>
                    <div class="col-md-4 imgas">
                        <p>颜色分类：驼色</p>
                        <p>尺码：35</p>
                    </div>
                </div>
                <!-- 右边 -->
                <div class="col-md-6">
                    <div class="col-md-3">￥65.00</div>
                    <div class="col-md-3 price">
                        <span><a href="#" class="subtraction">-</a></span><input type="text" value="1" class="num"><span><a href="#" class="addition">+</a></span>
                    </div>
                    <div class="col-md-3 money">￥65.00</div>
                    <div class="col-md-3 main">
                        <ul>
                            <li><a href="#">移入收藏夹</a></li><br/>
                            <li><a href="#">删除</a></li><br/>
                            <li><a href="#">相似宝贝</a></li>
                        </ul>
                    </div>
                </div>


            </div>

            <div class="row">
                <!-- 左边 -->
                <div class="col-md-6">
                    <div class="col-md-4 imgs">
                        <label><input type="checkbox" value="3" class="pricet"></label></li>
                        <span><img src="images/1.jpg" alt=""></span>
                    </div>
                    <div class="col-md-4 main">
                        <ul>
                            <li><a href="#">毛毛鞋女秋冬2017新款韩版平底女靴尖头<br/>裸靴兔毛马丁靴粗跟短靴女</a></li>

                        </ul>
                        <span class="card">
                                <img src="images/xcard.png" alt="">
                                <img src="images/hp.png" alt="">
                                <img src="images/sz.jpg" alt="">
                            </span>
                    </div>
                    <div class="col-md-4 imgas">
                        <p>颜色分类：驼色</p>
                        <p>尺码：35</p>
                    </div>
                </div>
                <!-- 右边 -->
                <div class="col-md-6">
                    <div class="col-md-3">￥65.00</div>
                    <div class="col-md-3 price">
                        <span><a href="#" class="subtraction">-</a></span><input type="text" value="1" class="num"><span><a href="#" class="addition">+</a></span>
                    </div>
                    <div class="col-md-3 money">￥65.00</div>
                    <div class="col-md-3 main">
                        <ul>
                            <li><a href="#">移入收藏夹</a></li><br/>
                            <li><a href="#">删除</a></li><br/>
                            <li><a href="#">相似宝贝</a></li>
                        </ul>
                    </div>
                </div>


            </div>


        </div>
        <!-- 店铺名称 -->
        <div class="row cart">
            <div class="col-md-6">
                <label><input type="checkbox" value="2" class="shop"><span class="all">店铺：</span></label></li>
                <span class="infoa">灰姑娘极品小店</span>
            </div>
        </div>
        <div class="header-a">
            <div class="row">
                <!-- 左边 -->
                <div class="col-md-6">
                    <div class="col-md-4 imgs">
                        <label><input type="checkbox" value="3" class="pricet"></label></li>
                        <span><img src="images/1.jpg" alt=""></span>
                    </div>
                    <div class="col-md-4 main">
                        <ul>
                            <li><a href="#">毛毛鞋女秋冬2017新款韩版平底女靴尖头<br/>裸靴兔毛马丁靴粗跟短靴女</a></li>

                        </ul>
                        <span class="card">
                            <img src="images/xcard.png" alt="">
                            <img src="images/hp.png" alt="">
                            <img src="images/sz.jpg" alt="">
                        </span>
                    </div>
                    <div class="col-md-4 imgas">
                        <p>颜色分类：驼色</p>
                        <p>尺码：35</p>
                    </div>
                </div>
                <!-- 右边 -->
                <div class="col-md-6">
                    <div class="col-md-3">￥65.00</div>
                    <div class="col-md-3 price">
                        <span><a href="#" class="subtraction">-</a></span><input type="text" value="1" class="num"><span><a href="#" class="addition">+</a></span>
                    </div>
                    <div class="col-md-3 money">￥65.00</div>
                    <div class="col-md-3 main">
                        <ul>
                            <li><a href="#">移入收藏夹</a></li><br/>
                            <li><a href="#">删除</a></li><br/>
                            <li><a href="#">相似宝贝</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <footer>
            <div class="col-md-6  amout">金额：</div>
            <div class=".col-md-6">总计：</div>
        </footer>
</body>
<script>
    $(document).ready(function () {
        $("#opt").click(function () {
            var an = $("#opt").is(":checked");
            console.log(an);
            if (an == true) {
                $("#opt").next().text("取消");
                $(".shop").add(".pricet").each(function (e) {
                    $(this).prop("checked", true)
                });
            } else {
                $("#opt").next().text("全选");
                $(".shop").add(".pricet").each(function (e) {
                    $(this).prop("checked", false)
                });
            }
        });
    });
</script>

</html>